]> git.neil.brown.name Git - wiggle.git/commitdiff
Fix exit status from 'diff'.
authorNeilBrown <neil@brown.name>
Mon, 7 Sep 2020 06:34:10 +0000 (16:34 +1000)
committerNeilBrown <neil@brown.name>
Mon, 7 Sep 2020 06:34:10 +0000 (16:34 +1000)
Exit status of 'diff' count the number of differences, then take low
bits.
This is nonsense.  Make it 1 if there are differences.

Signed-off-by: NeilBrown <neil@brown.name>
wiggle.c

index ca0b2602e16161ca3826a4510c6a65d0e3f90558..5d4685d807187b46f2507cbf0ce08a9fa3a08a05 100644 (file)
--- a/wiggle.c
+++ b/wiggle.c
@@ -209,7 +209,7 @@ static int do_diff_lines(struct file fl[2], struct csl *csl)
                                          fl[0].list[a]);
                        }
                        a++;
-                       exit_status++;
+                       exit_status = 1;
                } else if (b < csl->b) {
                        if (fl[1].list[b].start[0]) {
                                printf("+");
@@ -217,7 +217,7 @@ static int do_diff_lines(struct file fl[2], struct csl *csl)
                                          fl[1].list[b]);
                        }
                        b++;
-                       exit_status++;
+                       exit_status = 1;
                } else {
                        if (fl[0].list[a].start[0] == '\0')
                                printsep(fl[0].list[a],
@@ -239,12 +239,12 @@ static int do_diff_lines(struct file fl[2], struct csl *csl)
 static int do_diff_words(struct file fl[2], struct csl *csl)
 {
        int a, b;
-       int exit_status  = 0;
+       int exit_status = 0;
        int sol = 1; /* start of line */
        a = b = 0;
        while (a < fl[0].elcnt || b < fl[1].elcnt) {
                if (a < csl->a) {
-                       exit_status++;
+                       exit_status = 1;
                        if (sol) {
                                int a1;
                                /* If we remove a
@@ -282,7 +282,7 @@ static int do_diff_words(struct file fl[2], struct csl *csl)
                                sol = 0;
                        }
                } else if (b < csl->b) {
-                       exit_status++;
+                       exit_status = 1;
                        if (sol) {
                                int b1;
                                sol = 0;